﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using FirebirdSql.Data.FirebirdClient;

namespace University
{

    public partial class PIDROZDILY : University.TUOBJECT
    {
        static string sqlSelect = "SELECT * FROM PIDROZDILY";
        FbDataAdapter da = new FbDataAdapter(sqlSelect, con);
        DataTable dt = new DataTable();
        public PIDROZDILY()
        {
            InitializeComponent();
           
        }
        public PIDROZDILY(TreeNode node, ContextMenuStrip s, string com, int id)
            : base(node, s, com,id)
        {
            InitializeComponent();
            node_id = Convert.ToInt32(mynode.Tag.ToString());

            da.Fill(dt);
            bindingSource1.DataSource = dt;

            richTextBox1.DataBindings.Add("Text", bindingSource1, "MISTCE_ROZTAWYVANNJA");
            bindingSource1.Filter = "UNIQUE_NO =" + node_id;
            if (com == "Remove") { Remove("PIDROZDILY"); }
        }
        public override void Remove(string name)
        {
            base.Remove(name);
        }

        public override void UpdateForm()
        {
            OpenCon();
            UpdateFild("PIDROZDILY", "MISTCE_ROZTAWYVANNJA", richTextBox1.Text);
            base.UpdateForm();

        }
        public override void InsertFild(string klas)
        {
            OpenCon();
            FbCommand cmdInsert = new FbCommand("INSERT INTO PIDROZDILY(UNIQUE_NO,MISTCE_ROZTAWYVANNJA) VALUES(@1,@2)", con);
            cmdInsert.Parameters.AddWithValue("1", textBox1.Text);
            cmdInsert.Parameters.AddWithValue("2", richTextBox1.Text);
            cmdInsert.ExecuteNonQuery();
            base.InsertFild(klas);
        }
    }
}